package com.rd.student.jike.class4.wanghaixin.test0807;

import java.io.*;
import java.util.HashSet;

public class Testf {
    public static void main(String[] args) throws Exception {
        String s = getRandoms();
        Writer w = new FileWriter("daletou.txt");
        w.write(s);
        HashSet<String> ss = new HashSet<>();
        int i = 0;
        while(ss.size()<100){
//            System.out.println(getRandoms());
            String s11 = getRandoms();
            ss.add(s11);
        }
        System.out.println(ss);
        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("randomDLT.txt"));
        oos.writeObject(ss);
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream("randomDLT.txt"));
        HashSet<String> ss1 =(HashSet<String>)ois.readObject();
        System.out.println(ss1.size());
        for (String s1 : ss1) {
            if(s1.equals(s)){
                System.out.println(s + "中奖了");
            }else{
                System.out.println(s1 + "没中奖");
            }
        }

    }

    public static String getRandoms(){
        int[] nums = new int[7];
        for (int i = 0; i < 5; i++) {
            nums[i] = (int)(Math.random()*35)+1;
        }
        for (int i = 5; i < 7; i++) {
            nums[i] = (int)(Math.random()*12)+1;
        }
        String s = "";
        for (int i = 0; i < 5; i++) {
            s = s + nums[i] + " ";
        }
        s = s + " |";
        for (int i = 5; i < 7; i++) {
            s = s + " " +nums[i];
        }
        return s;
    }
}
